#include <iostream>
#include <string>
using namespace std;

void output(const string& str)
{
	int a = 0;
	int b = 0;
	while (a < (int)str.length())
	{
		b = str.find(' ', a);
		if (b == (int)string::npos) { b = str.length(); }
		
		if (a != 0) { cout << ' '; }
		for (int i = b-1; i >= a; --i)
		{
			cout << str[i];
		}		
		a = b + 1;
	}
	cout << endl;
}

int main(int argc, char **argv)
{
	int blockCount;
	string str;
	cin >> blockCount;
	for (int block = 0; block < blockCount; ++block)
	{
		if (block > 0) { cout << endl; }
		
		int caseCount;
		cin >> caseCount;
		while (cin.get() != '\n'); // clear input buffer
		while (caseCount--)
		{
			getline(cin, str);
			output(str);
		}
	}
	return 0;
}
